package com.storage.joyce.storageapp.util;

import android.app.Application;
import android.content.Context;
import android.os.Environment;

import org.kymjs.kjframe.KJBitmap;
import org.kymjs.kjframe.KJDB;
import org.kymjs.kjframe.bitmap.BitmapConfig;
import org.kymjs.kjframe.database.DaoConfig;

import java.io.File;

/**
 * Created by hua on 2015/8/4.
 */
public class MyApplication extends Application {
    public static Context context;
    public static int versionSdk = Integer.parseInt(android.os.Build.VERSION.SDK); // 设备SDK版本
    public static KJBitmap kjBitmap;
    public static BitmapConfig config;
    public static KJDB kjdb;
    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
        setKJFrame();
    }

    private void setKJFrame() {
        config = new BitmapConfig();
        config.CACHEPATH="xs1h/image";
        kjBitmap = new KJBitmap(config);
        DaoConfig daoConfig =new DaoConfig();
        daoConfig.setContext(context);
        daoConfig.setDbName("bbyjz8.db");
        daoConfig.setDbVersion(8);
        File file = new File( Environment.getExternalStorageDirectory(),"xs1h");
        if(!file.exists()){
            file.mkdirs();
        }
        File file2 = new File( Environment.getExternalStorageDirectory()+"/xs1h","image");
        if(!file2.exists()){
            file2.mkdirs();
        }
        daoConfig.setTargetDirectory(android.os.Environment.getExternalStorageDirectory()+"/"+"xs1h/");
        kjdb= KJDB.create(daoConfig);
    }
}
